package edu.xhu;

import edu.xhu.util.FileManager;
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.telephony.TelephonyManager;

public class XhuApplication extends Application{

	private String userIdEdu;						//用户登录教务系统的帐号
	private String passwordEdu;						//用户登录教务系统的密码
	private String userName;						//登录教务系统用户的名字
	private int role = 0;							//用户的角色，1-教师；2-学生；
	
	public static final int TEACHER		= 1;
	public static final int STUDENT		= 2;
	
	
	private String scheduleUrl;						//教务系统中请求课表的url
	private String examineUrl;						//教务系统中请求考试信息的url
	private String gradeUrl;						//教务系统中请求成绩的url
	private String refererUrl;						//教务系统中的referer
	
	private String teaNameListUrl;					//教师教务系统中的名单查询url
	private boolean isLogin=false;					//是否已经登录教务系统，true-已经登录
	
	private String mChannel;						// 渠道号码
	private String mImei;							// 手机imei号码
	private String version;
	
	public boolean isLogin() {
		return isLogin;
	}

	public void setLogin(boolean isLogin) {
		this.isLogin = isLogin;
	}
	public String getTeaNameListUrl() {
		return teaNameListUrl;
	}

	public void setTeaNameListUrl(String teaNameListUrl) {
		this.teaNameListUrl = teaNameListUrl;
	}
	public String getRefererUrl() {
		return refererUrl;
	}

	public void setRefererUrl(String refererUrl) {
		this.refererUrl = refererUrl;
	}

	public String getScheduleUrl() {
		return scheduleUrl;
	}

	public void setScheduleUrl(String scheduleUrl) {
		this.scheduleUrl = scheduleUrl;
	}

	public String getExamineUrl() {
		return examineUrl;
	}

	public void setExamineUrl(String examineUrl) {
		this.examineUrl = examineUrl;
	}

	public String getGradeUrl() {
		return gradeUrl;
	}

	public void setGradeUrl(String gradeUrl) {
		this.gradeUrl = gradeUrl;
	}

	
	
	public int getRole() {
		return role;
	}

	public void setRole(int role) {
		this.role = role;
	}

	public String getUserIdEdu() {
		return userIdEdu;
	}

	public void setUserIdEdu(String userIdEdu) {
		this.userIdEdu = userIdEdu;
	}

	public String getPasswordEdu() {
		return passwordEdu;
	}

	public void setPasswordEdu(String passwordEdu) {
		this.passwordEdu = passwordEdu;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getImei() {
		return this.mImei;
	}
	
	public String getChannel() {
		return this.mChannel;
	}
	@Override
	public void onCreate() {
		super.onCreate();
		ApplicationInfo info = null;
		try
		{
			info = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
			Object value = info.metaData.get("XIHUA_CLIENT_CHANNEL");
			mChannel = value.toString();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
		
		TelephonyManager telephonyManager= (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
		mImei=telephonyManager.getDeviceId();
		
		// 如果存在文件保存的数据，则将其删除。因为数据改用数据库保存
		FileManager.deleteConfigFile();
	}
}
